package com.example.reader.ui.read;

import android.os.Bundle;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.RelativeLayout;

import com.blankj.utilcode.utils.ToastUtils;
import com.example.reader.R;
import com.example.reader.ui.base.BaseActivity;
import com.example.reader.ui.read.view.BookView;

import butterknife.BindView;
import butterknife.ButterKnife;

import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;

public class ReadBookActivity extends BaseActivity {


    @BindView(R.id.activity_read_book)
    RelativeLayout activity_read_book;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();
        // fullscreen  全屏显示，不显示状态栏
        window.addFlags(FLAG_FULLSCREEN);
        setContentView(R.layout.activity_read_book);
        ButterKnife.bind(this);
        final BookView bookView = new BookView(this);
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        bookView.setLayoutParams(layoutParams);
        activity_read_book.addView(bookView);

        bookView.setPagerClickListenner(new BookView.PagerClickListenner() {
            @Override
            public void onClickLeft(BookView bookview) {
                ToastUtils.showShortToast("上一页");
                bookview.showBeforePage();
                super.onClickLeft(bookview);
            }

            @Override
            public void onClickRight(BookView bookview) {
                ToastUtils.showShortToast("下一页");
                bookview.showNextPage();
                super.onClickRight(bookview);
            }
        });
    }
}
